<?php

class UserController extends MController
{
	public function actionIndexpage()
	{
		$userid = $this->getRequest('userid', 0);
		$visitorid = $this->getRequest('visitorid', 0);
		$res['code'] = 0;
		$res['msg'] = '成功';
		$user = $this->model('User')->getUserById($visitorid, 'visitnum');
		$res['visitnum'] = $user['visitnum'];
		$res['fansnum'] = $this->model('Guanzhu')->getUserCount($visitorid);
		$res['dingyuenum'] = $this->model('Guanzhu')->getUserCountByUserID($visitorid);
		if ($userid == $visitorid) {
			echo json_encode($res);die;
		}
		if ($this->model('User')->addVisit($visitorid) !== false) {
			$this->model('Visitlog')->insert(array(
				'indexuserid' => $visitorid,
				'visituserid' => $userid,
				'createtime' => time()
			));
		}
		echo json_encode($res);die;
	}
}